Imports System.Data
Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TextBox1.Focus()
    End Sub

    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If e.KeyChar = ChrW(Keys.Enter) Then
            e.Handled = True
            TextBox2.Focus()
        End If
    End Sub

    Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.LostFocus
        Dim Ws As New WSConsulta.Service
        Dim ds As DataSet = Ws.SqlEjecutaSql("", "select unique(oracledba.getnombreubicacion(h.id_empresa,id_ubicacion)) origen from transaccion_header h , transaccion_detail d where h.numero_documento = '" + TextBox1.Text + "' and h.id_trx = d.id_trx")

        Try
            If ds.Tables.Count > 0 Then
                If ds.Tables(0).Rows.Count > 0 Then
                    TextBox4.Text = ds.Tables(0).Rows(0).Item("origen").ToString
                End If
            End If
        Catch ex As Exception
            MessageBox.Show("Ocurrio el siguiente Error" + ex.Message)
        End Try
        
    End Sub

    Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
        If e.KeyChar = ChrW(Keys.Enter) Then
            e.Handled = True
            TextBox3.Focus()
        End If
    End Sub

    Private Sub TextBox2_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.LostFocus
        Dim Ws As New WSConsulta.Service
        Dim ds As DataSet = Ws.SqlEjecutaSql("", "select h.fecha_transaccion, h.id_cliente, d.cantidad, d.precio_venta_unit, d.descuento_unitario from transaccion_header h , transaccion_detail d where h.numero_documento = '" + TextBox1.Text + "' and d.id_sku = '" + TextBox2.Text + "' and h.id_trx = d.id_trx")

        Try
            If ds.Tables.Count > 0 Then
                If ds.Tables(0).Rows.Count > 0 Then
                    TextBox5.Text = ds.Tables(0).Rows(0).Item(0).ToString
                    TextBox3.Text = ds.Tables(0).Rows(0).Item(1).ToString
                    TextBox6.Text = ds.Tables(0).Rows(0).Item(2).ToString
                    TextBox7.Text = ds.Tables(0).Rows(0).Item(3).ToString


                    'MessageBox.Show(ds.Tables(0).Rows(0).Item(1).ToString)
                    '"select * from tabla1 where nombre = '" + textbox1.text + "'"
                    'ds = WsConsuta.EjecutaSql("", "select * from tabla1 where nombre = '" + TextBox1.Text + "'")   3513464  260622044666
                    'select unique(oracledba.getnombreubicacion(h.id_empresa,id_ubicacion)) origen from transaccion_header h , transaccion_detail d where h.numero_documento = 3513464 and h.id_trx = d.id_trx
                End If
            End If
        Catch ex As Exception
            MessageBox.Show("Ocurrio el siguiente Error" + ex.Message)
        End Try
    End Sub
End Class
